using System;
using System.Collections.ObjectModel;
using GalaSoft.MvvmLight;
using System.Collections;
using MapInfo.Toolbox.UI.Services;

namespace MapInfo.Toolbox.UI.ViewModels
{
    public class ModuleTreeViewModel : ViewModelBase
    {
        private readonly IModuleLoader _moduleLoader;
        private GroupViewModel _groupViewModel;

        public ModuleTreeViewModel(IModuleLoader moduleLoader)
        {
            _moduleLoader = moduleLoader;

            this.Items = new ObservableCollection<ViewModelBase>();
        }

        public void LoadModules()
        {
            this._moduleLoader.LoadModules();

            _groupViewModel = new GroupViewModel("Group1");
            this.Items.Add(_groupViewModel);

            foreach (var module in this._moduleLoader.Modules)
            {
                ToolboxItemViewModel toolboxItemViewModel = new ToolboxItemViewModel(module.Value);
                Items.Add(toolboxItemViewModel);
            }
        }

        public ObservableCollection<ViewModelBase> Items { get; set; }
    }
}